﻿







// JScript 文件

///////////////////////////////////管线实体属性设置////////////////////////////////////////////
var ImageSize = function()
{
    this.vZoom = 1;//缩放倍数
    this.vimagsize = 120;//图片的大小







    //function
    this.SetZoom = function()
    {
         this.vZoom = 1 - (window.thisObj.m_MapCfg.m_MaxLevel - parseInt(window.inf[2]))/3;
         if(this.vZoom < 0.4)
             this.vZoom = 0.4
    }
    
    this.SetImageSize = function(vSize)
    {
       this.vimagsize = vSize;
    }
}

//标注显示比例
function TextSize()
{
    this.size = 2;
    this.addtop = 0;
    
    this.setTextSize = function()
    {
        switch(parseInt(window.thisObj.m_MapCfg.m_MaxLevel) - parseInt(window.inf[2]) + 1)
        {
           case 3:
                this.size = 1;
                this.addtop = -10;
                break;
           case 2:
                this.size = 1;
                this.addtop = -10;
                break;
           case 1:
                this.size = 2;
                this.addtop = -10;
                break;
           case 0:
                this.size = 3;
                this.addtop = -10;
                break;  
           default:
                this.size = 1;
                this.addtop = -10;
                break;                 
        }
    }
}


//////////////////////////////////////////////////////////////////////////////
//----------------------管线实体操作类------------------------
/////////////////////////////////////////////////////////////////////////////

function CtnMapGxEntOper(objName,mapObj)
{
    //域成员定义







    this.name = objName;            //实体操作的对象名
    
    this.mapObj = mapObj;           //地图对象
    
    this.displevel = mapObj.m_MapCfg.m_EntDispLevel;
    
    this.maxlevel  = mapObj.m_MapCfg.m_MaxLevel;
    
    this.preLevel = 0;              //前一次操作图层所在的级数
    
    this.operCode_DEF = {oper_loc_load:1,oper_loc:2,oper_move:3,oper_zoomin:4,oper_zoomout:5};
    
    this.operCode = 0;
    
    this.entRect = new D_RECT();    //屏幕地图的矩形区域


    this.bSvgDoc = false;
    
    this.queLinExp = "";
    
    this.quePntExp = "";


    
    this.locEntity  = null;         //当前定位实体的实体号 ID0
    this.major = null;
    this.minor = null;
    
    this.locEntType_DEF = {loc_pnt:1,loc_line:2,loc_rect:3};            // 1:当前定位的是点   2:当前定位的是线   3:  当前定位的是区







    
    this.locEntType = 1;
    
    this.m_vPntList = null;         //实体点列表







    
    this.m_vLinList = null;         //实体线列表







    
    this.m_PntshowCount = 0;        //点实体显示的历史次数
    
    this.m_LinshowCount = 0;        //线实体显示的历史次数
    
    this.m_maxPntShowCount = 0;     
    this.m_PntshowTimeOutID = null;
    this.m_LinshowTimeOutID = null;
    
    this.Flashcount = 0
    this.m_flashEnd = 0
    this.IntervalID = null;
    this.TimeOutID1 = null;
    
    this.TimeOutID_GX = null;
    
    this.m_dispEntNum = 80;        //每次显示实体的个数







     this.rectidList = new Array();//区域id
    this.m_vPntArray = new Array();
    this.m_vLinArray = new Array();
    
    this.flashNodes = new Array;        //当前定位闪烁的点列表
    
    this.ImageSizeObj = new ImageSize()
    this.TextSizeObj = new TextSize()
    
    this.EntList = new Array();
    
     this.vmlSam = new Array();      //vml缓存 [{id:"major1",vml:["<div></div>","<div></div>"]},{id:"minor2",vml:}]
    
    this.entSam = new Array();      //实体缓存 [{maj:1,min:1,id:,x0:,y0:,x1:,y1:},{maj:2,min:1,id:,x0:,y0:,x1:,y1:}]

    //function 声明
     this.DrawALin = DrawALin_GX;
    
    this.GetSamEntById = function (id){
        for(var i = 0; i < this.entSam.length; i++)
        {
            if(this.entSam[i].id.toString() == id.toString())
            {
               return this.entSam[i];
            }
        }
        return null;
    }
    
    this.clearSam = function(id)
    {
        for(var  i = 0; i < this.vmlSam.length; i++)
        {
            if(this.vmlSam[i].id.indexOf(id) > -1)
            {
               this.vmlSam[i].vml.length = 0;
            }
        }
    } 
    
    this.clearentSam = function(){
       if(this.entSam.length < 200) return;
      
       var bodyW = parseInt(document.body.clientWidth);
       var bodyH = parseInt(Math.max(document.documentElement.clientHeight, document.body.clientHeight));
  
       var rect = new D_RECT(-50, -50, bodyW + 50, bodyH + 50);
       
       for(var i = this.entSam.length - 1; i >= 0; i--)
       { 
         var ent =  this.entSam[i];
         
         if(parseInt(ent.maj) == 1)
         {
             var winxy = windowCoordinate(ent.x0, ent.y0, this.mapObj);
		      var pix = winxy[0];     
		      var piy = winxy[1];     		    
             var xpos = parseInt(pix);
             var ypos = parseInt(piy);
             
             if (!IsPntInRect(xpos,ypos, rect))
             {
                 if(this.bSvgDoc)
                 {
                     window.svgDrawPen.Undraw("Pnt" + ent.id);
                 }
                 var pnt = $("Pnt" + ent.id); 
                 pnt.parentNode.removeChild(pnt);
                 
                 this.entSam.splice(i,1);
             }      
          }
          else
          {
              var winS = windowCoordinate(ent.x0, ent.y0, this.mapObj);
		       var sl = winS[0];     
		       var st = winS[1];  
		       var winF = windowCoordinate(ent.x1, ent.y1, this.mapObj);
		       var fl = winF[0];     
		       var ft = winF[1];     
		       
               if (!IsLinInRect(sl, st, fl, ft, rect))
               {
                     if(this.bSvgDoc)
                     {
                        window.svgDrawPen.Undraw("Lin" + ent.id);
                     }
                     var lin = $("Lin" + ent.id); 
                     lin.parentNode.removeChild(lin);
               
                     this.entSam.splice(i,1);
               }
           }  
        }
    }
    
    this.InsertHtml = InsertHtml_GX;
    
    this.GetSamElem  = GetSamElem_GX;
    
    this.DrawAPnt_Pr = DrawAPnt_Pr;
    //设置取实体的矩形范围
    
    this.setRect = function(xMin,yMin,xMax,yMax)
    { 
        this.entRect.xMin = xMin;
        this.entRect.yMin = yMin;
        this.entRect.xMax = xMax;
        this.entRect.yMax = yMax;
    }

    //地图管线实体容器
    
    this.CreateDivMap = function()
    {
        this.divMap = document.createElement("div");
        
        this.divMap.style.position = "absolute"
        this.divMap.style.visibility = "visible"
       
        this.divMap.style.left = "0px"
	    this.divMap.style.top = "0px"
	    this.divMap.style.zIndex = 1
        this.divMap.id = "divmap"
        document.getElementsByTagName('BODY')[0].appendChild(this.divMap)
    }
    
    this.divMap = null;
    
    this.getGxEnt = getGxEnt_GX;
    
    this.ReDraw = ReDraw_GX;
    
    //鼠标按下的重绘----取点属性
    this.DownDraw = DownDraw_GX;
    
    //取管线实体
    this.UpDraw = UpDraw_GX;
    
    //显示管线实体
    
    this.dispGxEnt = dispGxEnt_GX;
    
    //显示新增区域的实体信息
    this.appendNewGxEnt = appendNewGxEnt_GX;
    
    //删除不在屏幕区的实体
    
    this.deleteOldGxEnt = deleteOldGxEnt_GX;
    
    //移动实体 
    
    this.MoveEntRect = MoveEntRect_GX;
    
    
    this.getNewAddGxEnt = getNewAddGxEnt_GX;
    /////得到管线图标的存储位置///////////
    
    this.getsrcbytype = getsrcbytype_GX;
    
    this.bDispEnt = bDispEnt_GX;
    //线实体渐显效果
    this.telLinEntFadein = function()
    {
       this.m_LinshowCount = 0
       this.linFadein()
       this.m_LinshowTimeOutID = setInterval(this.name + ".linFadein()",1000)	
    }

    //定时在页面上画线
    
    this.linFadein = linFadein_GX;
    
    //画线函数  
    
    this.GetLinGraph = GetLinGraph_GX;
   
    //点实体渐显效果
    this.telPntEntFadein = function()
    {
         this.m_PntshowCount = 0
	     this.pntFadein()
         this.m_PntshowTimeOutID = setInterval(this.name + ".pntFadein()",1000)	    
    }
    //定时在页面上画点

    this.pntFadein = pntFadein_GX;
    //画点函数  
    
    this.GetPntGraph = GetPntGraph_GX;
    //===================
    //画点实体
    //===================
    this.DrawPntTelEnt = DrawPntTelEnt_GX
    //=================
    //画线实体
    //=================
    this.DrawLinTelEnt = DrawLinTelEnt_GX;
    
    this.DownGetPoint  = DownGetPoint;      //向区域中添加点    this.DownGetDelMap = DownGetDelMap;     
    this.SaveDate = SaveDate;               //存储数据（区域操作） 
    this.DeleteDate = DeleteDate;           //删除数据（区域操作） 
    this.UpMouse = UpMouse;                 //鼠标弹起（区域操作）
    this.MoveMouse = MoveMouse;             //鼠标移动 （区域操作）
    
    this.EntityLocat = EntityLocat_GX;          // 实体定位
    
    //实体定位闪烁
    {
        this.DrawFlashPnt = DrawFlashPnt_GX;    //闪烁点实体
        this.DrawFlashLin = DrawFlashLin_GX;    //闪烁线实体
        this.FlashPicLin = FlashPicLin_GX;
        this.DispPicPnt = DispPicPnt_GX;
    }
    this.showPntAtt = showPntAtt_GX;         //显示定位的点的标注属性
    this.ClearFlash = ClearFlash_GX;         //清楚历史闪烁记录
    this.dispLocatEnt = dispLocatEnt_GX;     //闪烁定位的实体
    this.clearDivMap = clearDivMap_GX;       //清楚屏幕内的实体
    this.getBodyWH = getBodyWH_GX;           //得到屏幕的宽和高
    this.getRectPoint = getRectPoint_GX;     //得到点列表的包罗矩形的顶点信息
    this.getMapLevel = getMapLevel_GX;       //得到地图的级数（已知道地图的逻辑长度） 
    this.getEntByPoint = getEntByPoint_GX;   //得到鼠标点击的位置下的实体
    this.getEntByRect = getEntByRect_GX;     //得到矩形范围的实体列表
    this.getEntByCirc = getEntByCirc_GX;     //得到圆域范围的实体列表
    this.getEntByPoly = getEntByPoly_GX;     //得到多边形范围的实体列表
    this.showEntAtt = showEntAtt_GX;         //显示实体属性信息
    this.showEntSelList = showEntSelList_GX; //显示查询的实体列表
    this.getQueExp = getQueExp_GX;

    this.getGxEnt_Call =getGxEnt_Call;
    //把该对象添加到地图层
    window.UsualObjReDrawList.push(this);       
     
    this.init = function ()
    {
        this.CreateDivMap();
    }     
   
}

    //清楚界面上的实体
    
    function clearDivMap_GX()
    {
         try
         {
             if(this.divMap)
             {
                 this.entSam.length = 0; //清空缓存
                  
                 var vCount = this.divMap.childNodes.length;
                 for(var i = vCount - 1; i >= 0; i--)
                 {
                     this.divMap.removeChild(this.divMap.childNodes[i])
                 }
                 this.divMap.innerHTML = "";
                 closePntAtt();
                 
                 if(this.bSvgDoc)
                 {
                    window.svgDrawPen.clear();
                 }
             }
         }
         catch(e)
         {
             this.divMap.innerHTML = "";
         }
    }
    
    //刷新显示定位的实体







    function dispLocatEnt_GX()
    {
       
       if(this.m_flashEnd == 0)
       {
           switch(this.locEntType)
           {
               case 1:
                     this.DrawFlashPnt();
                     this.showPntAtt();
                     break;
               case 2:
                     this.DrawFlashLin();
                     break;
               case 3:
               
                     break;
               default:
                   
                     break;
           }
        }
    }
    
    //取管线实体
    
    function getGxEnt_GX()
    {
       var serverUrl = "";
       if(this.bDispClientEnt)
       {
                 //只显示当前实体，不取窗口中的其他实体
           serverUrl = "method=getRectEntList"
                    + "&xmin=" + escape(this.entRect.xMin)
                    + "&ymin=" + escape(this.entRect.yMin)
                    + "&xmax=" + escape(this.entRect.xMax)
                    + "&ymax=" + escape(this.entRect.yMax)
                    + "&quePntExp=" + escape("id0=") + this.locEntity
                    + "&queLinExp=1 <> 1";
       }
       else   
       {
       
           this.getQueExp();
           serverUrl = "method=getRectEntList"
                               + "&xmin=" + escape(this.entRect.xMin)
                               + "&ymin=" + escape(this.entRect.yMin)
                               + "&xmax=" + escape(this.entRect.xMax)
                               + "&ymax=" + escape(this.entRect.yMax)
                               + "&quePntExp=" + escape(this.quePntExp)
                               + "&queLinExp=" + escape(this.queLinExp);
       }    
       CtnTrans.Ajax("/handlers/MapHandler.ashx","post",serverUrl, this.getGxEnt_Call.bind(this),null, {loading:false});   
    }
    //取管线实体的回调函数
    
    function getGxEnt_Call(response)
    {
        this.dispGxEnt(response.responseText);
    }
    
    //鼠标按下取点属性
    function DownDraw_GX(e)
    {
        var operType = window.UserMapOper.ActiveTool.toString();
        switch(operType)
        {
            case "2098":        // 当前操作为点查询操作(查询点属性)
            case "20006":       //节点展开图
            case "20007":       //管道段截面展开图
            {
                var entList = this.getEntByPoint(null);
                if(entList.length == 0)
                {
                    return;
                }
                if(entList.length == 1)
                {
                   this.showEntAtt(entList[0],operType)
                }
                else
                {
                   this.showEntSelList(entList,operType)
                }
            }
            break;
            case "20008":          //修改覆盖范围
            {
                this.DownGetPoint();
            }
            break;
            case "20009":          //删除图形
            {
                this.DownGetDelMap();
            }
            break;
            default:
            break;
        }
        if(window.UserMapOper.ActiveTool == 1003)
        {
             if(this.TimeOutID1 != null && this.TimeOutID1 != "")
	         {
	             var vPnt    = $("Pnt" + this.locEntity); 
	             clearInterval(this.IntervalID)
                 clearInterval(this.TimeOutID1)
                 this.IntervalID = ""
    	         
                 this.m_flashEnd = 1
                
                 if(vPnt)
                 {
                     vPnt.style.visibility = "visible"; 
                 }
                 var num = 0;
                 while(true)
                 {  
                    var vLinVml = $("Flash_Lin" + num);
                    if(vLinVml)
                    {
                       //$("allInfoDiv").removeChild(vLinVml)
                       vLinVml.style.visibility = "visible";
                    }
                    else
                    {
                        break;
                    }
                    num++;
                 } 
             }
        }
        
    }
    
    //显示实体属性框
    
    function showEntAtt_GX(entObj,operType)
    {
        var major = entObj.major;
        var minor = entObj.minor;
        var entityNo = entObj.entityNo;
        if(parseInt(major) == 2 && parseInt(minor) == 10) return;
        if (parseInt(operType) == 20006)          //节点展开图
        {
            if (parseInt(major) == 1 && parseInt(minor) == 14)
            {
                top.ExecuteATool(top.m_vt.MAP_PNTEXPAND,[major, minor, entityNo]);
            }
            else{return;}
        }
        else if (parseInt(operType) == 20007)
        {
            if (parseInt(major) == 2 && parseInt(minor) == 11)
            {
                top.ExecuteATool(top.m_vt.MAP_GDDEXPAND,[major, minor, entityNo]);
            }
            else{return;}
        }
        else
        {
            top.ExecuteATool(top.m_vt.FUN_ATT,[major, minor, entityNo, "unadd", null, null]);
        }
    }
    
    //从实体列表里选择一实体  下一步  查看属性



    
    function showEntSelList_GX(EntObjList,operType)
    {
        var entCount = 0;
        var tempEntObj;
        var content = "<table width=100%>";
        
        for(var i = 0; i < EntObjList.length; i++)
        {
           var entObj = EntObjList[i]
           var vId = "Pnt" + entObj.entityNo;
           var vBm = "";
           if(!$(vId))
           {
              vId = "Lin" + entObj.entityNo;
              if(!$(vId) || entObj.minor == 10)  continue;
              var serverUrl = "_method=getEntityBmByNo"
                           + "&major=" + escape(entObj.major)
                           + "&minor=" + escape(entObj.minor)
                           + "&entityNo=" + escape(entObj.entityNo);
                           
                          
              vBm = top.CtnTrans.getText("/main.ashx?", "post", serverUrl)  
           }
           else
           {
               vBm = entObj.bm;
           }
           
           if (parseInt(operType) == 2098)     //属性查看




           {
               tempEntObj = entObj;
               content += "<tr width=100%>";
               content += "<td>";
               content += "<a href='javascript:top.ExecuteATool(top.m_vt.FUN_ATT,["+entObj.major+"," + entObj.minor + ","+entObj.entityNo+",null,null,null])'>" + vBm + "</a></td>";
               content += "</tr>";
               entCount++;
           }
           if (parseInt(operType) == 20006)     //节点展开图




           { 
               if (parseInt(entObj.major) != 1 || parseInt(entObj.minor) != 14)
               {
                    continue;
               }
               else
               {
                    content += "<tr width=100%>";
                    content += "<td>";
                    content += "<a href=\"javascript:top.ExecuteATool(top.m_vt.MAP_PNTEXPAND,[" + entObj.major;
                    content += + "," + entObj.minor + "," + entObj.entityNo + "])\">" + vBm + "</a></td>";
                    content += "</tr>";
                    tempEntObj = entObj;
                    entCount++;
               }
           }
           if (parseInt(operType) == 20007)      //管道段截面展开图




           {
               if (parseInt(entObj.major) != 2 || parseInt(entObj.minor) != 11)
               {
                    continue;
               }
               else
               {
                    content += "<tr width=100%>";
                    content += "<td>";
                    content += "<a href=\"javascript:top.ExecuteATool(top.m_vt.MAP_GDDEXPAND,[" + entObj.major;
                    content += + "," + entObj.minor + "," + entObj.entityNo + "])\">" + vBm + "</a></td>";
                    content += "</tr>";
                    tempEntObj = entObj;
                    entCount++;
               }
           }
        }
        
        content += "</table>";
        var params = {
                        //title: "选择一个实体（单击显示实体属性）",
                        title: "选择一个实体",
                        bmax: false,
                        bmin:false,
                        bmodal: true,
                        width:400,
                        height:300,
                        iconcss:null,
                        bresize:true,
                        arrbtn: [{text:"关 闭", onClick:function(dlg){dlg.close();}}]
                     }
        if (entCount == 0)
        {
//            if (parseInt(operType) == 20006)
//            {
//                top.CtnDlg.msg("请选择人手井实体查看节点展开图！");
//            }
//            else
//            {
//                top.CtnDlg.msg("请选择管道段实体查看管道段截面展开图！");
//            }
            return;
        }
        if (entCount == 1)
        {
            this.showEntAtt(tempEntObj,operType);
            return;
        }
        var dlg = top.CtnDlg.show(content,params);
        
    }
   
    //判断点击位置所在的实体
    
    function getEntByPoint_GX(major)
    {
         var vEntArr = new Array();
         var vX = parseInt(window.Mx);
         var vY = parseInt(window.My);
         
         
         try
         {
             for(var i = 0; i < this.entSam.length; i++)
             {
                 var entmaj = this.entSam[i].maj.toString();
                 if(!major || major.toString() == entmaj)
                 { 
                     if(entmaj == "1")
                     {
                         var pnt = $("Pnt" + this.entSam[i].id);
                         if(Position.within(pnt,vX,vY))
                         {
                             var vType = parseInt(this.entSam[i].type); 
                             var vEntNo = parseInt(this.entSam[i].id);
                             var pntArr = new TEL_ENTITYNO(1,vType,vEntNo)
                             pntArr.bm = this.entSam[i].bm;
                             
                             vEntArr.push(pntArr);
                         }
                     }
                     else if(entmaj == "2")
                     {
                         var ent = this.entSam[i];
                         
                         var winxy = windowCoordinate(ent.x0, ent.y0,this.mapObj)
		                  var sl = winxy[0];     
		                  var st = winxy[1];  
		                  winxy = windowCoordinate(ent.x1, ent.y1,this.mapObj)
		                  var fl = winxy[0];     
		                  var ft = winxy[1];       
                          
                         var vPnt = new D_Dot2D(vX,vY,false)
                         var vPnt1 = new D_Dot2D(sl,st,false)
                         var vPnt2 = new D_Dot2D(fl,ft,false)
                         var Dot_arr = new Array();
                         Dot_arr.push(vPnt1)
                         Dot_arr.push(vPnt2)
                         var rect = this.getRectPoint(Dot_arr);
                         if (IsPntInRect(vX,vY,rect))
                         {
                             if(IsDisPntToLin(vPnt,vPnt1,vPnt2))
                             {
                                 var vType = parseInt(ent.type) 
                                 var vEntNo = parseInt(ent.id)
                                 var LinArr = new TEL_ENTITYNO(2,vType,vEntNo)

                                 vEntArr.push(LinArr);
                             }
                         }
                     }
                 } 
             }
         }
         catch(e)
         {
            CtnDlg.msg(e.Message);
            vEntArr.length = 0;
            return vEntArr;
         }
         return vEntArr;
    }
    
    //取矩形框内的实体
    
    function getEntByRect_GX(Rect)
    {
         var vEntArr = new Array();
        
         for(var i = 0; i < this.entSam.length; i++)
         {
             if("1" == this.entSam[i].maj.toString())
             { 
                 var winxy = windowCoordinate(this.entSam[i].x0, this.entSam[i].y0,this.mapObj)
		              var x = winxy[0];     
		              var y = winxy[1];  
		              
                if(IsPntInRect(x, y, Rect))
                {
                    var vType = parseInt(this.entSam[i].type); 
                    var vEntNo = parseInt(this.entSam[i].id);

                    var ent = new TEL_ENTITYNO(1,vType,vEntNo);
                    ent.bm = this.entSam[i].bm;
                    vEntArr.push(ent);
                }
             }
         } 
       
         return vEntArr;
    }
    
     //取圆域内的实体



    function getEntByCirc_GX(circle)
    {
        var vEntArr = new Array();
        
        for(var i = 0; i < this.entSam.length; i++)
         {
             if("1" == this.entSam[i].maj.toString())
             { 
                 var winxy = windowCoordinate(this.entSam[i].x0, this.entSam[i].y0,this.mapObj)
		              var x = winxy[0];     
		              var y = winxy[1];  
		              
                if(IsPntInCircle(x, y, circle))
                {
                    var vType = parseInt(this.entSam[i].type); 
                    var vEntNo = parseInt(this.entSam[i].id);
                    var ent = new TEL_ENTITYNO(1,vType,vEntNo);
                    ent.bm = this.entSam[i].bm;
                    vEntArr.push(ent);
                }
             }
         } 
         return vEntArr;
    }
    
    //取多边内的实体


    function getEntByPoly_GX(Poly)
    {
        window.PolyPener.PenDc.Clear()
        window.PolyPener.PenDc.UnDraw();
        var i;
        var vEntArr = new Array();
        var windowCoor = new Array();
        var PQXarray = new Array();
        var PQYarray = new Array();
         try
         {
         
            for (i = 0; i < Poly.length; i++)
            {
                windowCoor = windowCoordinate(Poly[i].lx, Poly[i].ly, window.thisObj);
                PQXarray[i] = windowCoor[0];
                PQYarray[i] = windowCoor[1];
            }
            
            if (MapGxOperObj.divMap == null)
            {
                 return;
            }
             for(var i = 0; i < this.entSam.length; i++)
             {
                 if("1" == this.entSam[i].maj.toString())
                 { 
                     var winxy = windowCoordinate(this.entSam[i].x0, this.entSam[i].y0,this.mapObj)
		                  var x = winxy[0];     
		                  var y = winxy[1];  
    		              
                    if(CheckDotInPolygon(PQXarray, PQYarray, x, y))
                    {
                        var vType = parseInt(this.entSam[i].type); 
                        var vEntNo = parseInt(this.entSam[i].id);
                        var ent = new TEL_ENTITYNO(1,vType,vEntNo);
                        ent.bm = this.entSam[i].bm;
                        vEntArr.push(ent);
                        
                    }
                 }
             } 
         }
         catch(e)
         {
            CtnDlg.msg(e.Message);
            return;
         }
        
         //return vEntArr;
         if(vEntArr.length == 0)
        {
            return;
        }
        else
        {
            MapGxOperObj.EntList = vEntArr; 
            top.CreateEntTree();
            //top.m_doc.createWnd(new top.CtnTool(top.m_vt.MAP_PNTEXPAND,"实体图", "main", "Dialog/EntTree.htm"));
        }
        return;
    }
    
    function ReDraw_GX(e)
    {
        var bodyWidth  = 0;
		var bodyHeight = 0;
		
//		if(this.preLevel == parseInt(window.inf[2]))
//		{
//		   return;
//		}
        if(this.operCode == this.operCode_DEF.oper_loc_load)
        {
           this.operCode = 0;
           return;
        }
		this.preLevel = parseInt(window.inf[2])
		if(CtnBrowser.IE)
		{
		    bodyWidth  = window.$body.clientWidth;
		    bodyHeight  = document.documentElement.clientHeight;
		}
		else if(CtnBrowser.FF)
		{
		    bodyWidth  = document.documentElement.clientWidth;
		    bodyHeight  = document.documentElement.clientHeight;
		}
		//清楚上次界面上显示的实体
		this.clearDivMap();
		
		
		if(parseInt(window.inf[2]) + 1 >= parseInt(this.mapObj.m_MapCfg.m_EntDispLevel) && parseInt(this.mapObj.m_MapCfg.m_MaxLevel) >=  parseInt(window.inf[2]) + 1)
        {      
             top.CtnDlg.loading("正在取管线实体...");
             var logicMin = logicCoordinate(0,bodyHeight,thisObj);
	         var logicMax = logicCoordinate(bodyWidth,0,thisObj);
	         this.setRect(logicMin[0],logicMin[1],logicMax[0],logicMax[1]);
             this.getGxEnt();
        }
    }
    
    //取管线实体







    
    function UpDraw_GX(e)
    {
       
        
		var bodyWh = this.getBodyWH();
		var bodyWidth  = bodyWh[0];
		var bodyHeight = bodyWh[1];
		
		var xPix, yPix;
	    if(CtnBrowser.IE)
	    {
	        xPix = e.clientX;
	        yPix = e.clientY;
	    }
	    else if(CtnBrowser.FF)
	    {
	        xPix = e.pageX;
	        yPix = e.pageY;
	    }
    	
	    var dx = xPix - window.Mx;
	    var dy = yPix - window.My;
	    
	    if(window.UserMapOper.ActiveTool.toString() == "20008")          //修改覆盖范围
        {
            //重会区域，更新到库
            //更新点列表 this.flashnodes
            this.UpMouse();
        }
           
	      
	    if(parseInt(window.inf[2]) + 1 >= this.mapObj.m_MapCfg.m_EntDispLevel && this.mapObj.m_MapCfg.m_MaxLevel >=  parseInt(window.inf[2]) + 1)
        {      
            if(window.UserMapOper.ActiveTool == 1001 || window.UserMapOper.ActiveTool == 1002)
            { 
                if(this.preLevel == parseInt(window.inf[2]) || this.divMap == null)
		        {
		           return;
		        }
		        this.clearDivMap();
		        top.CtnDlg.loading("正在取管线实体...");
		        this.preLevel = parseInt(window.inf[2])
                var logicMin = logicCoordinate(0,bodyHeight,thisObj);
	            var logicMax = logicCoordinate(bodyWidth,0,thisObj);
	            this.setRect(logicMin[0],logicMin[1],logicMax[0],logicMax[1]);
	            
	            this.getGxEnt();
            }
     
            else if(window.UserMapOper.ActiveTool == 1003)
            {
                if((dx && dx != 0) || (dy && dy != 0))
                {
                    top.CtnDlg.loading("正在取管线实体...");
                    
                    this.setRect(dx,dy,dx,dy);
                    this.getNewAddGxEnt();
	            }
            }
            else if(top.m_vt.MAP_DRAWRECT == window.UserMapOper.ActiveTool)   //矩形查询
            {
                 var xMin = (dx > 0)? parseInt(window.Mx) : parseInt(xPix);
                 var xMax = (dx > 0)? parseInt(xPix) : parseInt(window.Mx);
                 var yMin = (dy > 0)? parseInt(window.My) : parseInt(yPix);
                 var yMax = (dy > 0)? parseInt(yPix) : parseInt(window.My);
                 var QueRect = new D_RECT(xMin,yMin,xMax,yMax)
                 var entList = this.getEntByRect(QueRect);
                 if(entList.length == 0)
                 {
                   return;
                 }
                 else
                 {
                    this.EntList = entList; 
                    top.CreateEntTree();
                 }
            }
            else if(top.m_vt.MAP_DRAWCIRCLE == window.UserMapOper.ActiveTool)   //圆域查询
            {
                 var r = Math.abs(Math.sqrt((window.Mx - xPix)*(window.Mx - xPix) + (window.My-yPix)*(window.My-yPix)));
                 var QueCirc = new D_RECT(window.Mx, window.My, r*2, r*2)
                 var entList = this.getEntByCirc(QueCirc);
                 if(entList.length == 0)
                 {
                   return;
                 }
                 else
                 {
                    this.EntList = entList; 
                    top.CreateEntTree();
                 }
            }
        }
    }
    
    
    function getNewAddGxEnt_GX()
    {
         var dx = this.entRect.xMin;
         var dy = this.entRect.yMin;
         this.deleteOldGxEnt(dx,dy);
	     this.appendNewGxEnt(dx,dy);
	     clearInterval(this.TimeOutID_GX)
    }

    //--------------显示管线实体------------------
    function dispGxEnt_GX(entxml)
    {
        try
        {
           var XmlDoc = top.CtnXML.getXmlDoc();
           if (XmlDoc != null)
           {
               if(this.divMap == null)
               {
                  this.CreateDivMap();
               }
             
               XmlDoc.loadXML(entxml);
               var nodes = XmlDoc.selectNodes('NewDataSet');
	           if(nodes.length == 0)
	           {
	              top.CtnDlg.unloading();
		           return;
	           }
	           else
	           {
	              for (i = 0; i < nodes.length; ++i)
	              {
	                  var vPnt = nodes[i].selectNodes("pnt");
	                  //this.DrawPntTelEnt(vPnt);
    	              this.GetPntGraph(vPnt); 
        	          
	                  var vLin = nodes[i].selectNodes("lin");
	                  //this.DrawLinTelEnt(vLin);
    	              this.GetLinGraph(vLin); 
	              }
	           }
           }
           else
           {
               top.CtnDlg.unloading();
           }
        }
        catch(e)
        {
            top.CtnDlg.unloading();
        } 
    }
    
    /////////////////////////////////////实体移动实现部分 ---- START----////////////////////////////////
    //显示新增区域的实体信息







    
    function appendNewGxEnt_GX(dx,dy)
    {
           var bodyWidth = parseInt(document.body.clientWidth);
           var bodyHeight = parseInt(Math.max(document.documentElement.clientHeight, document.body.clientHeight));
         
            var logicMinF = new Array();
            var logicMaxF = new Array();
            
            var label = 0;
            if (dx > 0 && dy >= 0)
            {
                logicMinF = logicCoordinate(0,bodyHeight,this.mapObj);
                logicMaxF = logicCoordinate(dx,0,this.mapObj);
                 
                logicMinS = logicCoordinate(dx,dy,this.mapObj);
                logicMaxS = logicCoordinate(bodyWidth,0,this.mapObj);
                
                label = 1;
            }
            else if (dx < 0 && dy <= 0)
            {
                logicMinF = logicCoordinate(0,bodyHeight,this.mapObj);
                logicMaxF = logicCoordinate(bodyWidth,bodyHeight+dy,this.mapObj);
                 
                logicMinS = logicCoordinate(bodyWidth+dx,bodyHeight+dy,this.mapObj);
                logicMaxS = logicCoordinate(bodyWidth,0,this.mapObj);
                
                label = 1;
            }
            else if (dx <= 0 && dy > 0)
            {
                logicMinF = logicCoordinate(0,dy,this.mapObj);
                logicMaxF = logicCoordinate(bodyWidth,0,this.mapObj);
                 
                logicMinS = logicCoordinate(bodyWidth+dx,bodyHeight,this.mapObj);
                logicMaxS = logicCoordinate(bodyWidth,dy,this.mapObj);
                
                label = 1;
            }
            else if (dx >= 0 && dy < 0)
            {
                logicMinF = logicCoordinate(0,bodyHeight,this.mapObj);
                logicMaxF = logicCoordinate(dx,0,this.mapObj);
                 
                logicMinS = logicCoordinate(dx,bodyHeight,this.mapObj);
                logicMaxS = logicCoordinate(bodyWidth,bodyHeight+dy,this.mapObj);
                
                label = 1;
            }
            if(label == 1)
            {
                var xmin = logicMinF[0] - 1;
                var ymin = logicMinF[1] - 1;
	            var xmax = logicMaxF[0] + 1;
	            var ymax = logicMaxF[1] + 1;
        	    
	            this.isGetEntEnd = true;  
	           
	            top.CtnDlg.loading("正在取管线实体...");
	            this.setRect(xmin,ymin,xmax,ymax);
	            
	            this.getGxEnt();
	            
                xmin = logicMinS[0] - 1;
                ymin = logicMinS[1] - 1;
                xmax = logicMaxS[0] + 1;
                ymax = logicMaxS[1] + 1;
                
	            this.setRect(xmin,ymin,xmax,ymax);
	        }
    }
    
    //删除不在屏幕区的实体
    
    function deleteOldGxEnt_GX(dx,dy)
    {
        var vRect;
    
        var bodyWidth = parseInt(document.body.clientWidth);
        var bodyHeight = parseInt(Math.max(document.documentElement.clientHeight, document.body.clientHeight));
        
        if (dx > 0 && dy >= 0)
        {
            vRect = new D_RECT(0, 0, (bodyWidth-dx), (bodyHeight - dy))
        }
        else if (dx < 0 && dy <= 0)
        {
            vRect = new D_RECT(-dx, -dy, bodyWidth, bodyHeight)
        }
        else if (dx <= 0 && dy > 0)
        {
            vRect = new D_RECT(-dx, 0, bodyWidth, bodyHeight-dy)
        }
        else if (dx >= 0 && dy < 0)
        {
            vRect = new D_RECT(0, -dy, (bodyWidth-dx), bodyHeight)
        }
        else
        {
            vRect = new D_RECT(0, 0, bodyWidth, bodyHeight)
        }
        this.divMap.style.left = parseInt(this.divMap.style.left) + dx + "px";
        this.divMap.style.top = parseInt(this.divMap.style.top) + dy + "px";
        
        this.clearentSam();
  
        //定位坐标的修正
        var EntLocDiv = $("TraceLocation")
        if(EntLocDiv && EntLocDiv.style.visibility == "visible")
        {
             EntLocDiv.style.left =  parseInt(EntLocDiv.style.left) + dx
             EntLocDiv.style.top  =  parseInt(EntLocDiv.style.top) + dy
        }
    }
    
    function MoveEntRect_GX(i,EntType,vRect,x,y)
    {
         if(EntType == "Pnt")
         {
             var childCount = (this.divMap.childNodes[i].childNodes.length)
               for(var j = childCount-1;j>=0;j--)
               {
                  
                   var vPnt = $(this.divMap.childNodes[i].childNodes[j].DevID)
                   if (!vPnt)
                   {
                       continue;
                   }
                   
                   var vPntLeft = vPnt.style.left.replace("px", "")
                   var vPntTop = vPnt.style.top.replace("px", "")
                   var vPntWidth = vPnt.style.width.replace("px", "")
                   var vPntHeight = vPnt.style.height.replace("px", "")
                   var xpos = parseInt(vPntLeft) + parseInt(vPntWidth / 2)
                   var ypos = parseInt(vPntTop) + parseInt(vPntHeight / 2)
                   
                   
                   var pntRect = new D_RECT((vRect.xMin - 50), (vRect.yMin - 50), (vRect.xMax + 50), (vRect.yMax + 50))
                   if (!IsPntInRect(xpos,ypos, pntRect))
                   {
                       if(this.bSvgDoc)
                       {
                           window.svgDrawPen.Undraw(this.divMap.childNodes[i].childNodes[j].DevID);
                       }
                       this.divMap.childNodes[i].childNodes[j].innerHTML = ""
                       this.divMap.childNodes[i].removeChild(this.divMap.childNodes[i].childNodes[j]);
                   }
                   else
                   {
                        vPnt.style.left =  parseInt(vPnt.style.left) + x + "px";
                        vPnt.style.top  =  parseInt(vPnt.style.top) + y + "px";
                        var vSpan = $("span"+divmap.childNodes[i].childNodes[j].DevID)
                        if(vSpan)
                        {
                             vSpan.style.left =  parseInt(vSpan.style.left) + x + "px";
                             vSpan.style.top  =  parseInt(vSpan.style.top) + y + "px";
                        }
                        
                        if(this.bSvgDoc)
                        {
                           var tmpobj = window.svgDrawPen.svgDoc.getElementById(this.divMap.childNodes[i].childNodes[j].DevID)
                           if(tmpobj)
                           {
                               tmpobj.setAttribute("x",  vPnt.style.left);
                               tmpobj.setAttribute("y",  vPnt.style.top);
                           }
                        }
                   }
                       
               } 
          }
         if(EntType == "Lin")
         {
           var childCount = (this.divMap.childNodes[i].childNodes.length)
               for(var j = childCount-1;j>=0;j--)
               {
                    var vLin = $(this.divMap.childNodes[i].childNodes[j].DevID)
                    if (vLin)
                    {
                       if (!IsLinInRect(vLin.Sl, vLin.St, vLin.Fx, vLin.Fy, vRect))
                       {
                           if(this.bSvgDoc)
                           {
                              window.svgDrawPen.Undraw(this.divMap.childNodes[i].childNodes[j].DevID);
                           }
                           this.divMap.childNodes[i].childNodes[j].innerHTML = ""
                           this.divMap.childNodes[i].removeChild(this.divMap.childNodes[i].childNodes[j])
                       }
                       else
                       {
                           vLin.Sl =  parseInt(vLin.Sl) + x;
                           vLin.St =  parseInt(vLin.St) + y;
                           vLin.style.left = vLin.Sl + "px";
                           vLin.style.top  = vLin.St + "px"; 
                           vLin.Fx =  parseInt(vLin.Fx) + x
                           vLin.Fy =  parseInt(vLin.Fy) + y
                           if(this.bSvgDoc)
                           { 
                                var tmpobj = window.svgDrawPen.svgDoc.getElementById(this.divMap.childNodes[i].childNodes[j].DevID)
                                if(tmpobj)
                                {
                                   tmpobj.setAttribute("x1", vLin.Sl + "px");
                                   tmpobj.setAttribute("y1", vLin.St + "px");
                                   tmpobj.setAttribute("x2", vLin.Fx + "px");
                                   tmpobj.setAttribute("y2", vLin.Fy + "px");
                                }
                           }
                      }
                   }
               }  
           }    
    }

        
    /////////////////////////////实体移动实现部分 ------END------//////////////////////////////////////
    //得到管线实体的图标物理位置/////
    function getsrcbytype_GX(type, map)
    {
        var src = "";
       
        switch (parseInt(type))
        {
            case CtnMinorDef.TEL_PNT_JZ:
                if(this.bSvgDoc)
                {
                    src = "images/dev/jz.gif"
                }
                else
                {
                    src = "images/dev/jz.png"
                }
                break;
            //case CtnMinorDef.TEL_PNT_ODF:
            //case CtnMinorDef.TEL_PNT_IDF:
            //case CtnMinorDef.TEL_PNT_GZDH:
            case CtnMinorDef.TEL_PNT_JF:
                if(this.bSvgDoc)
                {
                   src = "images/dev/jf.gif"
                }
                else
                {
                   src = "images/dev/jf.png"
                }
                break;
            case CtnMinorDef.TEL_PNT_DXJXS:
            case CtnMinorDef.TEL_PNT_GDZ:
                if(this.bSvgDoc)
                {
                   src = "images/dev/gdz.gif"
                }
                else
                {
                   src = "images/dev/gdz.png"
                }
                
                break;
            case CtnMinorDef.TEL_PNT_RSJ:
            {
                if(this.bSvgDoc)
                {
                    src = "images/dev/rsj.gif"
                    if (map == "2")
                    {
                        src = "images/dev/rsj.gif"
                    }
                    else if (map == "3")
                    {
                        src = "images/dev/rsj3.gif"
                    }
                    else if (map == "5")
                    {
                        src = "images/dev/rsj4.gif"
                    }
                }
                else
                {
                    src = "images/dev/rsj.png"
                    if (map == "2")
                    {
                        src = "images/dev/rsj.png"
                    }
                    else if (map == "3")
                    {
                        src = "images/dev/rsj3.png"
                    }
                    else if (map == "5")
                    {
                       src = "images/dev/rsj4.png"
                    }
                 }
            }
            break;
            case CtnMinorDef.TEL_PNT_DG:
                if(this.bSvgDoc)
                {
                    src = "images/dev/dg.gif"
                }
                else
                {
                    src = "images/dev/dg.png"
                }
                break;
            case CtnMinorDef.TEL_PNT_ZCD:
                if(this.bSvgDoc)
                {
                    src = "images/dev/zcd.gif"
                }
                else
                {
                    src = "images/dev/zcd.png"
                }
                break;
            case CtnMinorDef.TEL_PNT_YSD:
                if(this.bSvgDoc)
                {
                   src = "images/dev/ysd.gif"
                }
                else
                {
                   src = "images/dev/ysd.png"
                }
                break;
            case CtnMinorDef.TEL_PNT_DPQ:
                if(this.bSvgDoc)
                {
                   src = "images/dev/dpq.gif"
                }
                else
                {
                   src = "images/dev/dpq.png"
                }
                break;
            case CtnMinorDef.TEL_PNT_JJX:
            {
                if(this.bSvgDoc)
                {
                    src = "images/dev/jjx.gif"
                    if (map == "2" || map == "5")
                    {
                        src = "images/dev/jjx1.gif"
                    }
                    else if (map == "3" || map == "6")
                    {
                        src = "images/dev/jjx.gif"
                    }
                    else if (map == "4" || map == "7")
                    {
                       src = "images/dev/jjx2.gif"
                    }
                }
                else
                {
                    src = "images/dev/jjx.png"
                    if (map == "2" || map == "5")
                    {
                        src = "images/dev/jjx1.png"
                    }
                    else if (map == "3" || map == "6")
                    {
                        src = "images/dev/jjx.png"
                    }
                    else if (map == "4" || map == "7")
                    {
                       src = "images/dev/jjx2.png"
                    }
                }
            }
            break;
            case CtnMinorDef.TEL_PNT_DP:   //TEL_PNT_FXH:
                if(this.bSvgDoc)
                {
                    src = "images/dev/fxh.gif"
                }
                else
                {
                    src = "images/dev/fxh.png"
                }
                
                break;
            case CtnMinorDef.TEL_PNT_GHT:
                if(this.bSvgDoc)
                {
                    src = "images/dev/ght.gif"
                }
                else
                {
                    src = "images/dev/ght.png"
                }
                break; 
            case CtnMinorDef.TEL_PNT_WXJZ:
                if(this.bSvgDoc)
                {
                    src = "images/dev/wxjz.gif"
                }
                else
                {
                    src = "images/dev/wxjz.png"
                }
                break;
            case CtnMinorDef.TEL_PNT_GJJX:
                if(this.bSvgDoc)
                {
                   src = "images/dev/gjjx.gif"
                }
                else
                {
                   src = "images/dev/gjjx.png"
                }
                
                break;
            case CtnMinorDef.TEL_PNT_GFQH:
                if(this.bSvgDoc)
                {
                   src = "images/dev/gfqh.gif" 
                }
                else
                {
                    src = "images/dev/gfqh.png" 
                }
                break;
            case CtnMinorDef.TEL_PNT_ZPXX:
                if(this.bSvgDoc)
                {
                   src = "images/dev/zpxx.gif" 
                }
                else
                {
                   src = "images/dev/zpxx.png" 
                }
                break;
            case CtnMinorDef.TEL_PNT_YHD:
                if(this.bSvgDoc)
                {
                    src = "images/dev/yhd.gif" 
                }
                else
                {
                    src = "images/dev/yhd.png" 
                }
                break;
            default:
                break;
        }
        return src
    }
    
    ///////线实体渐显/////////////
    function linFadein_GX()
    {
        if(this.m_LinshowCount == this.m_maxLinShowCount)
        {
            clearInterval(this.m_LinshowTimeOutID)
        }
        else
        {
            this.GetLinGraph()
            this.m_LinshowCount++
        }      
    } 
    
    //画一条线
    
    function DrawALin_GX(linXml)
    {
        var vId   = $XML(linXml.selectNodes("ID0")[0]);
        var vType = $XML(linXml.selectNodes("TYPE")[0]);
        var vFnt  = $XML(linXml.selectNodes("FNTPNT")[0]);
        var vTal  = $XML(linXml.selectNodes("TALPNT")[0]);
        var vX0   = $XML(linXml.selectNodes("X0")[0]);
        var vY0   = $XML(linXml.selectNodes("Y0")[0]);
        var vX1   = $XML(linXml.selectNodes("X1")[0]);
        var vY1   = $XML(linXml.selectNodes("Y1")[0]);
        
        
        var lin = $("Lin" + vId);
        if(lin)
        {
            return;
        }
        var css = "hlcs";
        var DrawFlg = this.bDispEnt(2,parseInt(vType));
        if(DrawFlg[0] || DrawFlg[1]) css = "lcs";
        
        var wndS = windowCoordinate(parseFloat(vX0), parseFloat(vY0),this.mapObj)
	     var vDx1 = wndS[0] - parseInt(this.divMap.style.left);
	     var vDy1 = wndS[1] - parseInt(this.divMap.style.top);
	     var wndF = windowCoordinate(parseFloat(vX1), parseFloat(vY1),this.mapObj)
	     var vDx2 = wndF[0] - parseInt(this.divMap.style.left);
	     var vDy2 = wndF[1] - parseInt(this.divMap.style.top);
	    
	    
	    var samelem = this.GetSamElem("minor"+vType);
         if(samelem == null)
         {
             //添加一新的元素到缓存
             samelem ={id:"minor"+vType,vml:new Array()};  
             this.vmlSam.push(samelem); 
         }
         var tmpvml = samelem.vml;
         
         var ent = {maj:2,min:1,id:vId,x0:parseFloat(vX0),y0:parseFloat(vY0),x1:parseFloat(vX1),y1:parseFloat(vY1),type:vType};
         this.entSam[this.entSam.length] = ent;
         
         if(this.bSvgDoc)
         {
              if(DrawFlg[0] || DrawFlg[1])
	          {
	              var dotArr = new Array()
	              dotArr.push(new D_Dot2D(vDx1+"px",vDy1+"px"))
                  dotArr.push(new D_Dot2D(vDx2+"px",vDy2+"px"))
	              arg = {
                            id: "Lin" + vId, 
                            dotArr:dotArr,
                            strokeweight: "2px",
                            strokecolor: "black"
                         } 
                  window.svgDrawPen.drawLine(arg);
              }
         }
         else
         {
             tmpvml[tmpvml.length] = "<v:line id='Lin"+vId
                                 + "' class='" + css + "' style='LEFT:"+vDx1
                                 + "px;TOP:"+vDy1+"px' from='0,0' to='"+(vDx2-vDx1)
                                 + "px,"+(vDy2-vDy1)+"px'/>";
         }  
    }

    ///////得到线的图形信息/////////////////
    function GetLinGraph_GX(linlist)
    {     
       var maxvalue = linlist.length;
        
       this.clearSam("minor"); 
        
       for (var i = 0; i < maxvalue; ++i)
       {
          this.DrawALin(linlist[i]); 
       }
       
       this.InsertHtml("minor");  
        //线实体闪烁
        {
            if(this.locEntType == 2)
            {
                this.dispLocatEnt();
            }
            //如果是拖动实体则会发送两次取数据请求
           
            if(this.isGetEntEnd)
            {
              this.isGetEntEnd = false;  
              this.getGxEnt();
            }
            else
            {
              top.CtnDlg.unloading();
            }
        }
    } 
    
    
    function pntFadein_GX()
    {
        if(this.m_PntshowCount == this.m_maxPntShowCount)
        {
            clearInterval(this.m_PntshowTimeOutID)
        }
        else
        {
            this.GetPntGraph()
            this.m_PntshowCount++
        }    
    }   
    
    //从存储中得到元素 后面往该元素对象里插值 
    
    function GetSamElem_GX(id)
    {
        var samelem = null;
        
        for(var i = 0; i < this.vmlSam.length; i++)
        {
           if(id == this.vmlSam[i].id)
           {
               samelem = this.vmlSam[i];
           }
        }
        
        return samelem;
    }
    
    function DrawAPnt_Pr(pntNode)
    
    {
         //var w = parseInt(this.ImageSizeObj.vimagsize*this.ImageSizeObj.vZoom);
         //var h = parseInt(this.ImageSizeObj.vimagsize*this.ImageSizeObj.vZoom);
         var w = 80;
         var h = 80;
         
         var vId   = $XML(pntNode.selectNodes("ID0")[0]);
         var vType = $XML(pntNode.selectNodes("TYPE")[0]);
         var vRad  = $XML(pntNode.selectNodes("RAD")[0]);
         var vAng  = $XML(pntNode.selectNodes("ANG")[0]);
         var vX    = $XML(pntNode.selectNodes("X")[0]);
         var vY    = $XML(pntNode.selectNodes("Y")[0]);
         var vBz   = $XML(pntNode.selectNodes("BZ")[0]) || "";
         var vMap  = $XML(pntNode.selectNodes("MAP")[0]);
       
         
		  var wndMin1 = windowCoordinate(parseFloat(vX), parseFloat(vY),this.mapObj)
		  var vDx1 = wndMin1[0] - parseInt(this.divMap.style.left);
		  var vDy1 = wndMin1[1] - parseInt(this.divMap.style.top);
    	
         var vsrc = this.getsrcbytype(vType, vMap)
		  if(vsrc == "")
		  {
		     return;
	      }
         
         var samelem = this.GetSamElem("major"+vType);
         if(samelem == null)
         {
             //添加一新的元素到缓存
             samelem ={id:"major"+vType,vml:new Array()};  
             this.vmlSam.push(samelem); 
         }
         var tmpvml = samelem.vml;
         
         var DrawFlg = this.bDispEnt(1,parseInt(vType));
		  
		  var pcss = "pcs01";
		  var bzcs = DrawFlg[1] ? "bzcs" : "hbzcs";
		  if(parseInt(this.maxlevel) - parseInt(window.inf[2]) == 1)
		  {
		     if(!DrawFlg[0])
		     {
		         pcss = "hpcs01";
		     } 
		  }
		  else
		  {
		      pcss = DrawFlg[0] ? "pcs02" : "hpcs02";
		     
		      w = 50;
		      h = 50;   
		  }
		  
         var vPntdiv = $("Pnt" + vId);
		  if(vPntdiv)
		  {
//		      vPntdiv.style.visibility = DrawFlg[0] ? "visible" : "hidden";
//		      var tmpspan = $("spanPnt"+vId)
//		      if(tmpspan)
//		      { tmpspan.style.visibility = DrawFlg[1] ? "visible" : "hidden";}
		    
		      return; 
		  }
         
         
         var ent = {maj:1,min:1,id:vId,x0:parseFloat(vX),y0:parseFloat(vY),bm:vBz,type:vType};
         this.entSam[this.entSam.length] = ent;
         
         if(this.bSvgDoc)
         {
             tmpvml[tmpvml.length] = "<img id='Pnt"+vId; 
             tmpvml[tmpvml.length] = "' src='" + vsrc;
             tmpvml[tmpvml.length] = "' class='" + pcss + "' style='rotation:" + vRad;
             tmpvml[tmpvml.length] = ";LEFT:" + (vDx1-(w/2)) + "px;TOP:" + (vDy1-(h/2))+ "px;' />";
         }
         else
         {
             tmpvml[tmpvml.length] = "<v:image id='Pnt"+vId; 
             tmpvml[tmpvml.length] = "' src='" + vsrc;
             tmpvml[tmpvml.length] = "' class='" + pcss + "' style='rotation:" + vRad;
             tmpvml[tmpvml.length] = ";LEFT:" + (vDx1-(w/2)) + "px;TOP:" + (vDy1-(h/2))+ "px;' />";       
		  }
    	
		  tmpvml[tmpvml.length] = "<span id='spanPnt" + vId; 
		  tmpvml[tmpvml.length] = "' class='" + bzcs + "' style='LEFT:"+(vDx1-(w/2))
		                      + "px;TOP:" + (vDy1-25)+"px;' >" + vBz + "</span>";
    }
    
  
    function InsertHtml_GX(id)
    {
        var htmlSam = new Array();
        
        for(var i = 0; i < this.vmlSam.length; i++)
        {
            if(this.vmlSam[i].id.indexOf(id) > -1)
            {
               htmlSam = htmlSam.concat(this.vmlSam[i].vml);
            }
        }
        if(htmlSam.length > 0)
        {
        
            if(this.divMap.childNodes.length == 0)
            {
                this.divMap.innerHTML = "<div></div>";
            }
            
            new Insertion.Before(this.divMap.childNodes[0],htmlSam.join(""));
        }
    }
    
    function GetPntGraph_GX(pntlist)
    {       
        var maxvalue = pntlist.length;
      
       this.clearSam("major"); 
       
       for (var i = 0; i < maxvalue; ++i)
       {
          this.DrawAPnt_Pr(pntlist[i]);  
       }
      
       this.InsertHtml("major");
       //闪烁点
       {
           if(this.locEntType == 1)
           {
                this.dispLocatEnt();
           }
           
           //如果是拖动实体则会发送两次取数据请求
           
           if(this.isGetEntEnd)
           {
              this.isGetEntEnd = false;    
              this.getGxEnt(); 
           }
       }
    }
    
    
    //画点实体
    
    function DrawPntTelEnt_GX(vPnt)
    {
        this.m_vPntList = vPnt;

        this.m_maxPntShowCount = parseInt(vPnt.length/this.m_dispEntNum) + 1;
        this.telPntEntFadein()   
    }
 
    //画线实体
 
    function DrawLinTelEnt_GX(vLin)
    {
        this.m_vLinList = vLin;

         this.m_maxLinShowCount = parseInt(vLin.length/this.m_dispEntNum) + 1;
         this.telLinEntFadein() 
    }
    
    
    
    //--------------清楚历史闪烁记录--------------
    
    function ClearFlash_GX()
    {
        if(this.TimeOutID1 != null && this.TimeOutID1 != "")
	     {
	         var vPnt    = $("Pnt" + this.locEntity); 
	         clearInterval(this.IntervalID)
             clearInterval(this.TimeOutID1)
             this.IntervalID = ""
	         
             
             //线、区，闪烁结束标志




             this.m_flashEnd = 1
            
             if(vPnt)
             {
                 vPnt.style.visibility = "visible";
                 closePntAtt();
             }
             var num = 0;
             while(true)
             {  
                var vLinVml = $("Flash_Lin" + num);
                if(vLinVml)
                {
                   $("allInfoDiv").removeChild(vLinVml)
                }
                else
                {
                    break;
                }
                num++;
             } 
         }
    }

   //定位管线实体

   function EntityLocat_GX(major,minor,entityNo,ventXml,bDispClientEnt)
   {   
       if (!CtnError.validate(ventXml))
       {
           CtnError.show();
           return;
       }
       
       var vSplits = ventXml.split('||');
       if(vSplits.length == 2 && vSplits[0] == "err")
       {
           alert(vSplits[1]);
           return;
       }
       
       this.bDispClientEnt = bDispClientEnt;
       var XmlDoc = top.CtnXML.getXmlDoc();
       //清除前面的定位操作       

       this.clearDivMap();





       
       this.ClearFlash();
       
        while(this.flashNodes.length > 0)
        {
           this.flashNodes.pop();
        }
        this.locEntity = entityNo;
        this.major = major;
        this.minor = minor;
       if (XmlDoc != null)
       {
           this.rectidList = null;
           this.rectidList = new Array();
           XmlDoc.loadXML(ventXml);
           window.responseText = ventXml;
           var nodes = XmlDoc.selectNodes('Items/Item');
           for(var i = 0; i < nodes.length; i++)
           {
               var tmpDotList = new Array();
               var rectId = $XML(nodes[i],"gid");
               this.rectidList.push(rectId);
               var childNode = nodes[i].selectNodes("Pnt")
               for(var j = 0; j < childNode.length; j++)
               {
               
                   var vX = childNode[j].getAttribute("X");
                   var vY = childNode[j].getAttribute("Y");
                   var tmpDot = new D_Dot2D(parseInt(vX),parseInt(vY),true);
                   tmpDotList.push(tmpDot);
               }
               
               if(tmpDotList.length > 0)
               {
                   this.flashNodes.push(tmpDotList);
               }
           }
           
           var nodesCount = this.flashNodes.length;
           var vCenterL = 0;
           var vCenterR = 0;
           var vdisplevel = this.mapObj.m_MapCfg.m_MaxLevel;
           if(nodesCount == 0)
           {
               alert("取点坐标失败!");
               return;
           }  
           this.m_flashEnd = 0 
           if(nodesCount == 1 && this.flashNodes[0].length == 1)
           {
                // 点实体定位







                this.locEntType = 1;
                vCenterL = this.flashNodes[0][0].lx;
                vCenterR = this.flashNodes[0][0].ly;
           }
           else
           {
                // 线实体定位



                var tmpNoList = new Array();
                for(var i = 0; i < this.flashNodes.length; i++)
                {
                    for(var j = 0; j < this.flashNodes[i].length; j++)
                    {
                        tmpNoList.push(this.flashNodes[i][j])
                    }
                }



                this.locEntType = 2;
                var rectPoint = this.getRectPoint(tmpNoList);
                var dx = rectPoint.xMax - rectPoint.xMin;
	            var dy = rectPoint.yMax - rectPoint.yMin;
	            vCenterL = rectPoint.xMin + dx/2;
                vCenterR = rectPoint.yMin + dy/2;
                vdisplevel = this.getMapLevel(dx,dy);  //GetMapLevel
               
           }
           
           this.preLevel = parseInt(vdisplevel) - 1;
           
           this.operCode = this.operCode_DEF.oper_loc_load;
           //重置窗口
           {
               this.mapObj.JumpingMap(vCenterL,vCenterR,vdisplevel)
           }
           if(parseInt(this.mapObj.m_MapCfg.m_EntDispLevel) > vdisplevel)
           {
               if(this.locEntType == 2)
               {
                   this.clearDivMap();
                   this.dispLocatEnt();
               }
               return;
           }
           var vtmpWH = this.getBodyWH(); 
           var bodyWidth = vtmpWH[0];
           var bodyHeight = vtmpWH[1];
           
           top.CtnDlg.loading("正在取管线实体...");
           var logicMin = logicCoordinate(0,bodyHeight,this.mapObj);
	        var logicMax = logicCoordinate(bodyWidth,0,this.mapObj);
           this.setRect(logicMin[0],logicMin[1],logicMax[0],logicMax[1]);
           
//           if(bDispClientEnt)
//           {
//               //只显示当前实体，不取窗口中的其他实体
//                 var serverUrl = "method=getRectEntList"
//                           + "&xmin=" + escape(this.entRect.xMin)
//                           + "&ymin=" + escape(this.entRect.yMin)
//                           + "&xmax=" + escape(this.entRect.xMax)
//                           + "&ymax=" + escape(this.entRect.yMax)
//                           + "&quePntExp=" + escape("id0=") + entityNo
//                           + "&queLinExp=1 <> 1";
//        
//                 CtnTrans.Ajax("/handlers/MapHandler.ashx","post",serverUrl, this.getGxEnt_Call.bind(this),null, {loading:false});
//           }
//           else
           {
	           this.getGxEnt();  
               
           }  
       }
   }


// 闪烁点实体  
function DrawFlashPnt_GX()
{
    var vId = "Pnt" + this.locEntity;
    
    this.Flashcount = 0
    this.m_flashEnd = 0
	this.FlashPicLin(vId)
    this.TimeOutID1 = setInterval(this.name +".FlashPicLin('"+vId+"')",40000)		
}


//闪烁点实体  
function  FlashPicLin_GX(vId)
{  
	    if(this.IntervalID != "")
	    {   
		    this.DispPicPnt(vId,true);
		    clearInterval(this.IntervalID)
	    }
	    if(this.Flashcount==8)//停止闪烁
	    {
		    this.DispPicPnt(vId,true);
		    clearInterval(this.TimeOutID1)
		    this.m_flashEnd = 1
		    return
	    }
	    this.DispPicPnt(vId);//隔0.4秒闪烁图标 
	    this.IntervalID = setInterval(this.name + ".DispPicPnt('"+vId+"')",800);
	    this.Flashcount=this.Flashcount + 1
    
}

function DispPicPnt_GX(vId,bVis)
{  
    var objList = new Array();
    if( this.locEntType == 1)
    {
        var vPntData = $(vId)
        objList.push(vPntData)
    }
    else
    {
        var num = 0;
        while(true)
        {
           var tmpId = vId +"" + num;
           var vPntData = $(tmpId)
           if(vPntData)
           {
               objList.push(vPntData)
           }
           else
           {
               break;
           }
           num++;
        }
    }
    
    for(var i = 0; i < objList.length; i++)
    {
        var vPntData = objList[i];
        if(!vPntData)
        {
           continue;
        }
        if(bVis)
        {
            vPntData.style.visibility = "visible";
        }
        else
        {
	        if(vPntData.style.visibility == "visible")
	        {
		        vPntData.style.visibility = "hidden";
	        }
	        else
	        {
		        vPntData.style.visibility = "visible";
	        }
	    }
	}   
}

function closePntAtt()
{
    var EntLocDiv = $("TraceLocation")
    if(EntLocDiv)
       EntLocDiv.style.visibility = "hidden";
}
//闪烁线实体








function DrawFlashLin_GX()
{
    var num = 0;
//    var allinfodiv = $("allInfoDiv");
//    for(var i = allinfodiv.childNodes.length - 1; i >= 0 ;i--)
//    {
//        allinfodiv.removeChild(allinfodiv.childNodes[i])
//    }
//    allinfodiv.innerHTML = "";
    
    for(var j = window.UserReDrawObj.length - 1; j >= 0; j--)
        {
           var id = window.UserReDrawObj[j].id;
           if(id)
           {
               if(id.indexOf("Flash_Lin") > -1) 
               {
                    window.UserReDrawObj[j].UnDraw();
                    
                    window.UserReDrawObj.splice(j,1);
               }
           }
        }
    
    //画新的图形
    var bRect = true;
    for(var i = 0; i < this.flashNodes.length; i++)
    {
         if((this.flashNodes[i][0].lx !=this.flashNodes[i][this.flashNodes[i].length - 1].lx) 
        || (this.flashNodes[i][0].ly !=this.flashNodes[i][this.flashNodes[i].length - 1].ly))
        {
            bRect = false;
            break;
        }
    }
    for(var i = 0; i < this.flashNodes.length; i++)
    {
        arg = { id:"Flash_Lin" + i, 
                name:"Flash_Lin" + i, 
                zIndex: "12",
                classStyle:" ",
                strokeweight: "3px", 
                strokecolor: "red", 
                stroked: false,
                filled : bRect,
                OnMouseOver: null,
                onmouseClick: null,
                dotArr: this.flashNodes[i]
             }
        var flashLine = new PolyLineShape(arg);
        flashLine.Draw();
     }   
 
    this.Flashcount = 0
    this.m_flashEnd = 0
    
    if(!bRect)
    {
	    this.FlashPicLin("Flash_Lin")
        this.TimeOutID1 = setInterval(this.name +".FlashPicLin('Flash_Lin')",40000)	
    }
    
     //从重绘列表中把历史绘图对象删除
    
   
        for(var j = window.UserReDrawObj.length - 1; j >= 0; j--)
        {
           var id = window.UserReDrawObj[j].id;
           if(id)
           {
               if(id.indexOf("Flash_Lin") > -1) 
               {
                    
               }
           }
        }
}

//显示定位的点的属性信息
function showPntAtt_GX()
{
    var entityno = this.locEntity;
    
    var ent = this.GetSamEntById(this.locEntity);
    if(ent     ==  null 
    || ent.type == CtnMinorDef.TEL_PNT_ODF 
    || ent.type == CtnMinorDef.TEL_PNT_IDF
    || ent.type == CtnMinorDef.TEL_PNT_GZDH)
    {
         var serverUrl = "_method=GetEntityZt&major=1&id0=" + this.locEntity;
         entityno = top.CtnTrans.getText("/main.ashx?", "post", serverUrl)  
         if (!CtnError.validate(entityno))
         {
              CtnError.show();
         }
         
         ent = this.GetSamEntById(entityno);
    }
    var MajorType = 1;
    if(vPnt)
    {
        var winxy = windowCoordinate(ent.x0, ent.y0, this.mapObj);
		 var pix = winxy[0];     
		 var piy = winxy[1];   
		 
        var MinorType = ent.type;
        var url = "javascript:top.ExecuteATool(top.m_vt.FUN_ATT,["+MajorType+","+MinorType+","+entityno+",null,null,null])";
        var szHtm =  "<table bgcolor='white' border='0' cellspacing='0' cellpadding='0' background='img/mappole/map_bomer_dt_039.gif'><tr><td width='7'><img src='Images/mappole/map_bomer_dt_038a.gif' width='7' height='32'></td><td width='18'><img src='Images/mappole/mapLeft.gif' border='0'></td>";
	    szHtm += "<td background='Images/mappole/mapMid.gif'>详细信息</td><td><img src='Images/mappole/closeDiv1.gif' onclick=closePntAtt()></td>";
	    szHtm += "<td width='18'><img src='Images/mappole/mapRight.gif' border='0'></td></tr><tr><td></td><td background='Images/mappole/map_BLeft.gif'></td>";
	    szHtm += "<td height='50' align='center' background=Images/Map/map_bomer_dt_039.gif><table border='0' cellspacing='0' cellpadding='0'><tr><td align=center><strong>编码："+ent.bm+"</strong></td></tr><tr><td align=center><a id='attribute' href='"+url+"'><font color=red>查看实体属性</font></a></td></tr></table></td><td></td><td background='Images/mappole/map_BRight.gif'></td></tr><tr><td></td>";
	    szHtm += "<td colspan='4'><table cellpadding='0' cellspacing='0' border='0' ><tr><td><img src='Images/mappole/map_bomerLeft.gif'></td>";
	    szHtm += "<td width='100%' background='Images/mappole/map_bomerMid.gif'></td><td><img src='Images/mappole/map_bomerRight.gif'></td></tr></table></td></tr></table>";
        
         var EntLocDiv = $("TraceLocation")
         if(!EntLocDiv)
         {
            EntLocDiv = document.createElement("div");
        
            EntLocDiv.id = "TraceLocation"
            document.getElementsByTagName('BODY')[0].appendChild(EntLocDiv)
         }
         EntLocDiv.innerHTML = szHtm;
         EntLocDiv.style.zIndex = 10000;
         EntLocDiv.style.position = "absolute";
         EntLocDiv.style.visibility = "visible";
         EntLocDiv.style.left = pix + "px";
         EntLocDiv.style.top  = piy + "px";  
    }	
}

function getRectPoint_GX(nodes)
{
    var minPntX, minPntY, maxPntX, maxPntY
	for (var i = 0; i < nodes.length; i++)
	{
	    var pntX = parseInt(nodes[i].lx)
	    var pntY = parseInt(nodes[i].ly)
		if (i == 0)
		{
			minPntX = pntX
			minPntY = pntY
			maxPntX = pntX
			maxPntY = pntY
		} 
		else
		{
			minPntX = (minPntX > pntX) ? pntX : minPntX
			minPntY = (minPntY > pntY) ? pntY : minPntY;
			maxPntX = (maxPntX > pntX) ? maxPntX  : pntX;
			maxPntY = (maxPntY > pntY) ? maxPntY  : pntY;
		}
	}
	
	return new D_RECT(minPntX,minPntY,maxPntX,maxPntY);
}


function getMapLevel_GX(dx,dy)
{
    var dispLevel = this.mapObj.m_MapCfg.m_MaxLevel;
    var initRate = this.mapObj.imgSize / this.mapObj.logicXlength
    var rateLevel = new Array();
    for(var i = 0;i < this.mapObj.m_MapCfg.m_MaxLevel;i++)
	{
		var rate = initRate*Math.pow(2, i + 1);
		rateLevel.push(rate);
	}
	var tmpRate;
	dx = Math.abs(dx);
	dy = Math.abs(dy);
	var vtmpWh = this.getBodyWH()
	var bodyWidth = vtmpWh[0];
	var bodyHeight = vtmpWh[1];
	if(dx > dy)
		tmpRate = bodyWidth / dx;//
	else
		tmpRate = bodyHeight / dy;
	for(var i = 0; i < rateLevel.length;i++)
	{
		if(tmpRate < rateLevel[i]) 
		{  
			dispLevel = i - 1; 
			break;
		}
	}
	return dispLevel
}


 function getBodyWH_GX()
 {
    var bodyWidth  = 0;
	var bodyHeight = 0;
	if(CtnBrowser.IE)
	{
	    bodyWidth  = window.$body.clientWidth;
	    bodyHeight  = document.documentElement.clientHeight;
	}
	else if(CtnBrowser.FF)
	{
	    bodyWidth  = document.documentElement.clientWidth;
	    bodyHeight  = document.documentElement.clientHeight;
	}
	return [bodyWidth,bodyHeight];
 }
 
 
 function getQueExp_GX()
 {
     var dispObj = this.mapObj.m_MapCfg.m_entDispList;
     var tmpObj = null;
     var entDisp = false;
     var bzDisp = false;
     this.quePntExp = "";
     this.queLinExp = "";
     for(var i = 0; i < dispObj.length; i++)
     {
         if(dispObj[i].level == (parseInt(window.inf[2]) + 1))
         {
             tmpObj = dispObj[i].dispList;
             break;
         }
     }
     if(tmpObj == null)
     {
         return;
     }
     var vCountPnt = 0;
     var vCountLin = 0;
     for(var j = 0; j < tmpObj.length; j++)
     {
         if(tmpObj[j].entDisp)
         {
             if(parseInt(tmpObj[j].maj) == 1)   
             {
                vCountPnt++;
                if(this.quePntExp.length > 0)
                {
                    this.quePntExp += " or type=" + tmpObj[j].min;
                }
                else
                {
                    this.quePntExp = " type=" + tmpObj[j].min;
                }
             }
             else
             {
                 vCountLin++;
                 if(this.queLinExp.length > 0)
                 {
                    this.queLinExp += " or type=" + tmpObj[j].min;
                 }
                 else
                 {
                    this.queLinExp = " type=" + tmpObj[j].min;
                 }
             }
             
         }
     }
     if(vCountPnt > 8)
     {
         this.quePntExp = "";
     }
     else if(vCountPnt == 0)
     {
         this.quePntExp = "1 <> 1";
     }
     if(vCountLin > 2)
     {
         this.queLinExp = "";
     }
     else if(vCountLin == 0)
     {
         this.queLinExp = "1 <> 1";
     }
     
 }
 
 
 // 当前级数的某类实体是否显示







 
 function bDispEnt_GX(maj,min)
 {
     var dispObj = this.mapObj.m_MapCfg.m_entDispList;
     var tmpObj = null;
     var entDisp = false;
     var bzDisp = false;
     for(var i = 0; i < dispObj.length; i++)
     {
         if(dispObj[i].level == (parseInt(window.inf[2]) + 1))
         {
             tmpObj = dispObj[i].dispList;
             break;
         }
     }
     if(tmpObj == null)
     {
         return [entDisp,bzDisp];
     }
     for(var j = 0; j < tmpObj.length; j++)
     {
         if(parseInt(maj) == tmpObj[j].maj && parseInt(min) == tmpObj[j].min)
         {
             entDisp = tmpObj[j].entDisp;
             bzDisp = tmpObj[j].bzDisp;
             break;
         }
     }
     return [entDisp,bzDisp];
 }
 
 
 
   //判断点到线的距离的是否 <= 4px   
   //三点构造成三角行，判断点vPnt到对边的距离是否小于4px
   //
   
   function IsDisPntToLin(vPnt,vPnt1,vPnt2)
   {
        var returnVal = false;
        var x = vPnt.lx;
        var y = vPnt.ly;
        
        var x1 = vPnt1.lx;
        var y1 = vPnt1.ly;
        
        var x2 = vPnt2.lx;
        var y2 = vPnt2.ly;
        
        
        var b = Math.sqrt((x - x1)*(x - x1) + (y - y1)*(y - y1));
        var d = Math.sqrt((x - x2)*(x - x2) + (y - y2)*(y - y2));
        var m = Math.sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
        var dis = Math.sqrt(b*b - ((m*m + b*b - d*d)/2/m)*((m*m + b*b - d*d)/2/m))
        if(dis <= 4)
        {
           returnVal = true;
        }
        return returnVal;
   }
   
 
 
    //判断点是否在矩形框内
    
    function IsPntInRect(x, y, rect)
    {
        var vIs = false
        if ((x>=rect.xMin)&&(x<=rect.xMax)&&(y>=rect.yMin)&&(y<=rect.yMax))
        {
            vIs = true 
        }
        return vIs;
    }

    //判断点是否在圆区域内
    
    function IsPntInCircle(x, y, circle)
    {
        var vIs = false
        var vR = circle.xMax / 2
        
        var xLong = Math.abs(circle.xMin - x);
        var yLong = Math.abs(circle.yMin - y);
        
        if (Math.sqrt(Math.pow(xLong, 2) + Math.pow(yLong, 2)) <= vR)
        {
            vIs = true
        }
        return vIs;
    }
    //判断线是否在矩形框内
    
    function IsLinInRect(x0, y0, x1, y1, rect)
    {
        var vIs = false
        
        var xmin = (x0 < x1)? x0:x1
        var ymin = (y0 < y1)? y0:y1
        var xmax = (x0 > x1)? x0:x1
        var ymax = (y0 > y1)? y0:y1
        if (xmin<=rect.xMax  && ymin <= rect.yMax && xmax >=rect.xMin  && ymax >= rect.yMin)
        {
            vIs = true
        }
        return vIs;
    }
function DownGetPoint()//获得当前的点 down事件
{


     window.lCod = -1;
    //判断该点是否在线上
     window.rectIndex = 0;
     
     var logicMinS = window.logicCoordinate(window.Mx,window.My,this.mapObj);
	 window.vMapX = logicMinS[0];
	 window.vMapY = logicMinS[1];
	 var vPnt = new D_Dot2D(window.vMapX,window.vMapY,false)
    //判断点到线的距离的是否 <= 4px
	 var vPolyCnt = 1;//区域个数
	 //首先找到鼠标点击的位子（在哪个区域的 哪条边上）
	 for(var i = 0;i < this.flashNodes.length ; i++)
	 {
	      for(var j = 0; j < this.flashNodes[i].length - 1;j++)
	      {
	          var vPnt1 = new D_Dot2D(this.flashNodes[i][j].lx,this.flashNodes[i][j].ly,false)
              var vPnt2 = new D_Dot2D(this.flashNodes[i][j+1].lx,this.flashNodes[i][j+1].ly,false)
              var lDoc = 1;
              //创建新的Xml图形信息
              if(IsDisPntToLin(vPnt,vPnt1,vPnt2))
              {
                  window.lCod = j;
                  window.rectIndex = i;
                  break;
              }
	      }
	 }

}
function DownGetDelMap()
{
    window.isinclud = false;
    //判断该点是否在线上
     window.rectIndex = 0;
     
     var logicMinS = window.logicCoordinate(window.Mx,window.My,this.mapObj);
//	 window.vMapX = logicMinS[0];
//	 window.vMapY = logicMinS[1];
//	 var vPnt = new D_Dot2D(window.vMapX,window.vMapY,false)
    //判断点到线的距离的是否 <= 4px
	 var vPolyCnt = 1;//区域个数
	 //首先找到鼠标点击的位子（在哪个区域的 哪条边上）
	 
	 for(var i = 0;i < this.flashNodes.length ; i++)
	 {
	      var mapxarray = new Array();
	      var mapyarray = new Array();
	      for(var j = 0; j < this.flashNodes[i].length;j++)
	      {
	          mapxarray.push(this.flashNodes[i][j].lx);
	          mapyarray.push(this.flashNodes[i][j].ly);
	      }
	      if(CheckDotInPolygon(mapxarray,mapyarray,logicMinS[0], logicMinS[1]))
          {
              window.isinclud = true;
              window.rectIndex = i;
              break;
          }
	 }
}
function MoveMouse(evt)
{
}
function UpMouse(evt)
{
    if(window.lCod >= 0)//点在线上
    {    
          var gid = this.rectidList[window.rectIndex];
          var nodes = this.flashNodes[window.rectIndex];
          for(var j = nodes.length - 1; j >window.lCod ;j --)
          {
             var vX = nodes[j].lx;
             var vY = nodes[j].ly;
             nodes[j+1] = nodes[j]
             if((j - 1) == window.lCod)//下一个位置就是要添加新的点的位置
             {
                  var x = event.clientX;
                  var y = event.clientY;
                  var logicMinS = window.logicCoordinate(x,y,this.mapObj);//this.mapObj为空的？
	              var newpnt = new D_Dot2D(logicMinS[0],logicMinS[1],true);
                  nodes[j] = newpnt;
             }
          }
        this.DrawFlashLin();
        //SaveDate();
    }
    else 
    {
        return;
    }
}
function SaveDate()// 保存数据,双击事件
{
    //gid区域id
    //entyId 经理id
    var GrouphXml =  BuildXm(this.flashNodes[window.rectIndex]);
    var vParam = "_method=Update&major="+this.major + "&minor=" +this.minor+"&jlId="+this.locEntity+"&DotXml="+GrouphXml+"&gid="+this.rectidList[window.rectIndex] ;
    var xmlDoc = CtnTrans.getText("/main.ashx", "post", vParam)
    if (!CtnError.validate(xmlDoc))
    {
        CtnError.show();
        return;
    }
}
function DeleteDate()
{
    if (confirm("确认是否删除该区域？"))
    {
        var vParam = "_method=DeleteMap&major="+this.major + "&minor=" +this.minor+"&gid="+this.rectidList[window.rectIndex] ;
        var xmlDoc = CtnTrans.getText("/main.ashx", "post", vParam)
        if(xmlDoc == "")
        {
            for(var i = this.flashNodes.length-1; i>=0;i--)
            {
                if(i == window.rectIndex)
                {
                    this.flashNodes.splice(i,1);
                }
            }
            for(var i = this.rectidList.length-1; i>=0;i--)
            {
                if(i == window.rectIndex)
                {
                    this.rectidList.splice(i,1);
                }
            }
            
            this.DrawFlashLin();
            top.CtnDlg.msg("删除成功!");
        }
        else if (!CtnError.validate(xmlDoc))
        {
            CtnError.show();
            return;
        }
    }
}
function BuildXm(flashnodes)
{
    if (flashnodes.length > 0)
    {
        var XmlDot = "<Items>"
        XmlDot += "<Item>";
        for(var j = 0 ; j < flashnodes.length ; j++)
        {
            XmlDot+="<Pnt X=\""+flashnodes[j].lx+"\" Y=\""+flashnodes[j].ly+"\"></Pnt>"
        }
        XmlDot += "</Item>";
        XmlDot += "</Items>";
    }
     return XmlDot;
}